export default {
  data() {
    return {
      checked: false,
      height: 90,
      companyId: '',
      mobile: '',
      jobName: '',
      name: ''
    }
  },
  onLoad(op) {
    console.log(this.$store.state.companyId, '公司id')
    // this.companyId = op.companyId
    this.companyId = this.$store.state.companyId
  },
  created() {

  },
  methods: {

    //判断手机号是否注册
    async checkUserIsRegister() {
      if (this.mobile.trim().length !== 11) return false
      // console.log(this.mobile)
      if (!(/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.mobile))) {
        this.$u.toast('请输入正确的手机号')
      }
    },
    change(status) {
      this.checked = status
      console.log(status)
    },
    //邀请
    async doInviteUser() {
      try {
        let data = {
          'CompanyId': this.companyId, //公司id 'f1b343b44a6648c68349d406b62e0c7a'
          'Mobile': this.mobile,
          'JobName': this.jobName, //职务
          'IsAdmin': this.checked, //是否管理员
          'TrueName': this.name //姓名
        }
        const res = await this.$api.company.DoInviteUser(data)
        console.log(res)
        this.$u.toast('邀请成功')
        setTimeout(res => {
          uni.navigateBack({
            delta: 1,
          })
        }, 1000)
      } catch (e) {
        console.log(e)
      }
    },
  },
}
